package com.utils2;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Date;

/**
 * @author LWY
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProvinceData {
    int confirmed;
    int recovered;
    int deaths;
    int total;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    Date date;
    ArrayList<City> today;



    public int getRecovered() {
        // 定义一个临时变量temp，用于存储所有城市的确诊人数
        int temp = 0;
        // 获取当前城市的所有数据
        ArrayList<City> citySum = this.today;
        for (City city: citySum) {
            temp += city.getCityData().recovered;
        }
        return  temp;
    }

    public int getDeaths() {
        // 定义一个临时变量temp，用于存储所有城市的确诊人数
        int temp = 0;
        // 获取当前城市的所有数据
        ArrayList<City> citySum = this.today;
        for (City city: citySum) {
            temp += city.getCityData().deaths;
        }
        return  temp;
    }

    public int getConfirmed() {
        // 定义一个临时变量temp，用于存储所有城市的确诊人数
        int temp = 0;
        // 获取当前城市的所有数据
        ArrayList<City> citySum = this.today;
        for (City city: citySum) {
            temp += city.getCityData().confirmed;
        }
        return  temp;
    }
    public int getTotal() {return this.confirmed+this.recovered+this.deaths;}


}
